package com.aidex.biz.service.impl;

import java.util.List;
import com.aidex.common.annotation.DataScope;
import com.aidex.common.core.redis.RedisCache;
import com.github.pagehelper.PageInfo;
import com.aidex.common.core.domain.entity.SysUser;
import com.aidex.common.core.domain.entity.SysDept;
import com.aidex.common.core.service.BaseServiceImpl;
import com.aidex.framework.cache.DeptUtils;
import com.aidex.framework.cache.UserUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.aidex.biz.mapper.BusinessSetMapper;
import com.aidex.biz.domain.BusinessSet;
import com.aidex.biz.service.BusinessSetService;
import org.springframework.transaction.annotation.Transactional;
import com.aidex.common.utils.NumberUtils;

/**
 * 业务设置Service业务层处理
 * @author sean
 * @email 2074844820@qq.com
 * @date 2024-04-25
 */
@Service
@Transactional(readOnly = true)
public class BusinessSetServiceImpl extends BaseServiceImpl<BusinessSetMapper, BusinessSet> implements BusinessSetService
{
    private static final Logger log = LoggerFactory.getLogger(BusinessSetServiceImpl.class);
    @Autowired
    private RedisCache redisCache;

    /**
     * 获取单条数据
     * @param businessSet 业务设置
     * @return 业务设置
     */
    @Override
    public BusinessSet get(BusinessSet businessSet)
    {
        BusinessSet dto =   super.get(businessSet);

        return dto;
    }

    /**
     * 获取单条数据
     * @param id 业务设置id
     * @return 业务设置
     */
    @Override
    public BusinessSet get(String id)
    {
        BusinessSet dto = redisCache.getCacheObject(id);
        if(null==dto){
            dto=super.get(id);
            redisCache.setCacheObject(id,dto);
        }
        return dto;
    }


    /**
     * 查询业务设置列表
     * @param businessSet 业务设置
     * @return 业务设置
     */
    @Override
    @DataScope(userAlias = "a",deptAlias = "a")
    public List<BusinessSet> findList(BusinessSet businessSet)
    {
        return super.findList(businessSet);
    }

    /**
     * 分页查询业务设置列表
     * @param businessSet 业务设置
     * @return 业务设置
     */
    @Override
    @DataScope(userAlias = "a",deptAlias = "a")
    public PageInfo<BusinessSet> findPage(BusinessSet businessSet)
    {
        return super.findPage(businessSet);
    }

    /**
     * 保存业务设置
     * @param businessSet
     * @return 结果
     */
    @Override
    public boolean save(BusinessSet businessSet)
    {
        redisCache.setCacheObject("index_set",businessSet);
        return super.save(businessSet);
    }


    /**
     * 删除业务设置信息
     * @param businessSet
     * @return 结果
     */
    @Override
    public boolean remove(BusinessSet businessSet)
    {
        return super.remove(businessSet);
    }

    /**
     * 批量删除业务设置
     * @param ids 需要删除的业务设置ID
     * @return 结果
     */
    @Transactional(readOnly = false)
    @Override
    public int deleteBusinessSetByIds(String[] ids)
    {
        return mapper.deleteBusinessSetByIds(ids);
    }

    /**
     * 获取最大编号
     * @param businessSet 业务设置
     * @return 结果
     */
    @Override
    public int findMaxSort(BusinessSet businessSet)
    {
        return NumberUtils.nextOrder(mapper.findMaxSort(businessSet));
    }
}
